<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>新闻管理|<{$configcache['Title']}></title>
    <link rel="stylesheet" type="text/css" href="__CSS__/content.css"  />
    <link rel="stylesheet" type="text/css" href="__CSS__/public.css"  />
    <script type="text/javascript" src="__JS__/jquery.js"></script>
    <script type="text/javascript" src="__JS__/Public.js"></script>
    <script type="text/javascript" src="__JS__/winpop.js"></script>
    <script type="text/javascript" src="__JS__/check.js"></script>
    <style type="text/css">
    .tc{text-align: center;border:1px solid #999;}
    .fixed_w { width:100px; }
    .fixed_w .oper { padding:0px 6px; color:#060; }
    </style>

    <script>
    $(document).ready(function() {
            //删除
            $('#content #table .tr .del').click(function(event) {
                event.preventDefault();
                if (!confirm('确定要删除该数据吗？')) {
                    return false;
                }
                var id=$(this).attr('href');
                if (id=='' || isNaN(id)) {
                    wintq('ID参数不正确',3,1000,1,'');
                    return false;
                }else {
                    wintq('正在删除，请稍后...',4,20000,0,'');
                    $.ajax({
                        url:'__APP__/News/newsdel/',
                        dataType:'json',
                        type:'POST',
                        data:'id='+id,
                        success: function(data) {
                            if (data.s=='ok') {
                                wintq('删除成功',1,1500,1,'?');
                            }else {
                                wintq(data.s,3,1500,1,'');
                            }
                        }
                    });
                }
            });


            //批量删除
            $('#dely').click(function(event) {
                event.preventDefault();
                if (!confirm('确定要删除选择项吗？')) {
                    return false;
                }
                var delid='';
                for (i=0; i<$('#table .delid').size(); i++) {
                    if (!$('#table .delid').eq(i).attr('checked')==false) {
                        delid=delid+$('#table .delid').eq(i).val()+',';
                    }
                }
                if (delid=='') {
                    wintq('请选中后再操作',2,1500,1,'');
                }else {
                    wintq('正在删除，请稍后...',4,20000,0,'');
                    $.ajax({
                        url:'__APP__/News/newsindel/',
                        dataType:'JSON',
                        type:'POST',
                        data:'delid='+delid,
                        success: function(data) {
                            if (data.s=='ok') {
                                wintq('删除成功',1,1500,0,'?');
                            }else {
                                wintq(data.s,3,1500,1,'');
                            }
                        }
                    });
                }
            });

});
</script>
</head>
<body>
    <div id="content">
        <h1>首页 > 新闻管理 > 文章管理</h1>
        <h2>
            <div class="h2_left">
                <a href="__ACTION__" class="whole">全部</a>
                <a href="javascript:;" class="f5" onclick="f5();">刷新</a>
                <a href="javascript:;" class="add" onclick="javascript:location.href='__APP__/News/add'">添加</a>
                <a href="javascript:history.back();" class="Retreat">后退</a>
                <a href="javascript:history.go(1);" class="Advance">前进</a>
            </div>
        </h2>
        <table id="table" border="1" bordercolor="#CCCCCC" cellpadding="0" cellspacing="0">
            <tr>
                <th>标题</th>
                <th>所属分类</th>
                <th>是否置顶</th>
                <th>操作用户id</th>
                <th>时间</th>
                <th>审核</th>
                <th>操作</th>
            </tr>

            <volist name="volist" id="vo">
                <tr>
                    <td class="tc"><{$vo.title}></td>
                    <td class="tc">
                        <!-- 使用switch标签判断输出 -->
                        <switch name="vo.news_type">
                            <case value="1">九科头条</case>
                            <case value="2">火热报名</case>
                            <case value="3">最新合作学校</case>
                            <case value="4">最新基地</case>
                            <default />
                        </switch>
                    </td>
                    <td class="tc">
                        <!-- 使用switch标签判断输出 -->
                        <switch name="vo.is_top">
                            <case value="1">置顶</case>
                            <case value="0">否</case>
                            <default />否
                        </switch>
                        <a href="javascript:;" class="top" status = '1' style="color:#FF9933" sid='<{$vo.sid}>'>推荐</a>&nbsp;&nbsp;<a href="javascript:;" class="notop" status = '0' style="color:#FF9933" sid='<{$vo.sid}>'>不推荐</a>
                    </td>
                    <td class="tc">管理员</td>
                    <td class="tc"><{$vo.create_time}></td>
                     <td class="tc fixed_w">
                        <switch name="vo.check_status">
                            <case value="0"><a href="javascript:;" class="pass" status = '1' style="color:#FF9933" sid='<{$vo.sid}>'>通过</a>&nbsp;&nbsp;<a href="javascript:;" class="nopass" status = '2' style="color:#FF9933" sid='<{$vo.sid}>'>不通过</a></case>
                            <case value="1">已审核<a href="javascript:;" class="pass" status = '1' style="color:#FF9933" sid='<{$vo.sid}>'>通过</a>&nbsp;&nbsp;<a href="javascript:;" class="nopass" status = '2' style="color:#FF9933" sid='<{$vo.sid}>'>不通过</a></case>
                            <case value="2">已审核<a href="javascript:;" class="pass" status = '1' style="color:#FF9933" sid='<{$vo.sid}>'>通过</a>&nbsp;&nbsp;<a href="javascript:;" class="nopass" status = '2' style="color:#FF9933" sid='<{$vo.sid}>'>不通过</a></case>
                            <default/>
                        </switch>
                    </td>
                    <td class="tc fixed_w"><a href="__APP__/News/edit/sid/<{$vo.sid}>" class="edit oper">修改</a><div style="cursor:pointer;color:red;" onclick="delapp('<{$vo.sid}>');">删除</div></td>
                </tr>
            </volist>
        </table>
        <div id="page">
            <{$page}>
        </div>
    </div>

    <script type="text/javascript">



 $('.top').click(function(){
        var sid= ($(this).attr('sid'));
        $.ajax({
            type: "POST",
            url: "<{$url}>/eduWeb/news/updateNewIstop",
            data: {istop:1,sid:sid},
            success: function(data){
                if(data.code == 2000){
                    alert('通过');
                    f5();
                }else{
                    alert('网络异常,请稍后再试');
                }
            }
        });
    });

    $('.notop').click(function(){
        var sid= ($(this).attr('sid'));
     
            $.ajax({
                type: "POST",
                url: "<{$url}>/eduWeb/news/updateNewIstop",
                data: {istop:0,sid:sid},
                success: function(data){
                    if(data.code == 2000){
                        alert('不通过');
                        f5();
                    }else{
                        alert('网络异常,请稍后再试');
                    }
                }
            });
    });



 $('.pass').click(function(){
        var sid= ($(this).attr('sid'));
        $.ajax({
            type: "POST",
            url: "<{$url}>/eduWeb/news/updateNewStatus",
            data: {status:1,sid:sid,comment:'通过'},
            success: function(data){
                if(data.code == 2000){
                    alert('审核通过');
                    f5();
                }else{
                    alert('网络异常,请稍后再试');
                }
            }
        });
    });

    $('.nopass').click(function(){
        var sid= ($(this).attr('sid'));
        layer.prompt({title: '请输入拒绝原因', formType: 2}, function(comment, index){
            layer.close(index);
            $.ajax({
                type: "POST",
                url: "<{$url}>/eduWeb/news/updateNewStatus",
                data: {status:2,sid:sid,comment:comment},
                success: function(data){
                    if(data.code == 2000){
                        alert('审核不通过');
                        f5();
                    }else{
                        alert('网络异常,请稍后再试');
                    }
                }
            });
        });
    });

    /*删除单个*/
    function delapp(sid){
        $.ajax( {
            url:'<{$url}>/eduWeb/news/deleteNews',// 跳转到 action
            data:{sid:sid},
            type:'post',
            cache:false,
            dataType:'json',
            success:function(data) {
                if(data.code =="2000" ){
                    alert(data.message);
                    location.reload();
                }else{
                    alert(data.message);
                }
            },
            error : function() {
                alert("异常！");
            }
        });
    }
    </script>
</body>
</html>